package com.common.file.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.io.File;

/**
 * @author 牧鱼
 * @Classname FileConfig
 * @Description TODO
 * @Date 2021/8/16
 */
@Component
@ConfigurationProperties(prefix = "file.config")
public class FileConfig {


    /**
     *  上传路径 获取项目下基本路径，作为默认路径
     */
    private static String winProfile = System.getProperty("user.dir");
    private static String linuxProfile = System.getProperty("user.dir");

    public static String getWinProfile() {
        return winProfile;
    }

    public static void setWinProfile(String winProfile) {
        FileConfig.winProfile = winProfile;
    }

    public static String getLinuxProfile() {
        return linuxProfile;
    }

    public static void setLinuxProfile(String linuxProfile) {
        FileConfig.linuxProfile = linuxProfile;
    }

    public static String getProfile() {
        if (File.separator.equals("\\")){
            return getWinProfile();
        }
        return getLinuxProfile();
    }

    /**
     * 获取下载路径
     */
    public static String getDownloadPath() {
        return getProfile() + "/download/";
    }
}
